package blog.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.UserService;

import blog.entity.User;
import blog.mapper.UserMapper;

@Service
public class UserServiceImpl implements UserService{
	//持久层对象
	@Autowired
	private UserMapper userMapper ;
	
	
	//根据用户名或密码登录
	public User getUserByNameOrEmail(String str) {
		return userMapper.getUserByNameOrEmail(str); 
	}

	//添加用户
	public int addUser(User user) {
		return userMapper.addUser(user);
	}


	//查询列表
	public List<User> ListUser() {
		return userMapper.ListUser();
	}


	//根据id获取用户
	public User getUserById(Integer userId) {
		return userMapper.getUserById(userId);
	}

	@Override
	public PageInfo<User> ListUser(Integer pageIndex, Integer pageSize) {
		
		PageHelper.startPage(pageIndex, pageSize);
		
		List<User> userList = userMapper.ListUser();
		
		return new PageInfo<User>(userList);
	}
}
